<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/element.css" />
		<link rel="stylesheet" type="text/css" href="css/reset.css" />
		<link rel="stylesheet" type="text/css" href="css/bg2.css" />
		<link rel="stylesheet" type="text/css" href="css/common.css" />
		<script src="js/jquery-3.5.1.js"></script>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/element.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			[v-cloak] {
				display: none;
			}
		</style>
	</head>
	<body>
		<div id="app"  v-cloak>
			<div class="page_root bg2_page">
				<el-card class="box-card" shadow="never">
					<div class="bg1_top">
						<span>广州市农作物种子质量检验中心</span>
					</div>
					<div class="title title1">检 验 结 果 报 告 单</div>
					<div class="bg1_form">
						<el-form :model="form" label-width="140px">
							<el-row>
								<el-col :span="8">
									<el-form-item label="报告编号:">
										<span>{{form.bgNo}}</span>
									</el-form-item>
								</el-col>
								<el-col :span="8" :offset="8">
									<el-form-item label="样品登记号:">
										<span>{{form.ypNo}}</span>
									</el-form-item>
								</el-col>
							</el-row>
							<div class="bj2_content">
								<table class="bg2_table">
									<tr>
										<th style="min-width: 30px">序号</th>
										<th style="min-width: 30px">检验项目</th>
										<th colspan="5">实测结果</th>
										<th style="min-width: 50px">质量标准(注)值</th>
										<th style="min-width: 50px">容许差距</th>
										<th style="min-width: 50px">单项判定</th>
									</tr>
									<tr>
										<td rowspan="3">1</td>
										<td rowspan="3">净度分析</td>
										<td colspan="2" style="min-width: 200px">净种子%</td>
										<td colspan="2" style="min-width: 200px">其他作物种子%</td>
										<td style="min-width: 130px">杂质%</td>
										<td rowspan="3">{{form.si}}</td>
										<td rowspan="3">{{form.deviation1}}</td>
										<td rowspan="3">{{form.result1}}</td>
									</tr>
									<tr>
										<td colspan="2">
											<div class="input_td">
												<el-input v-model='form.param1' @input="siInput" type="number"></el-input>
											</div>
										</td>
										<td colspan="2">
											<div class="input_td">
												<el-input v-model='form.param2' ></el-input>
											</div>
										</td>
										<td>
											<div class="input_td">
												<el-input v-model='form.param3' ></el-input>
											</div>
										</td>
									</tr>
									<tr>
										<td colspan="4" @click="dialog1=true">
                                            <div style="text-align: left;padding-left: 10px">其他植物种子的种类及数目：{{form.param15}}。</div>
                                            <div style="text-align: left;padding-left: 10px">杂质的种类：{{form.param16}}。</div>
                                        </td>
										<td>
											<div class="input_td">
												<el-select v-model="form.param4">
													<el-option label="--" value="--"></el-option>
													<el-option label="完全检验" value="完全检验"></el-option>
													<el-option label="有限检验" value="有限检验"></el-option>
													<el-option label="简化检验" value="简化检验"></el-option>
												</el-select>
											</div>
										</td>
									</tr>
									<tr>
										<td rowspan="4">2</td>
										<td rowspan="4">发芽试验</td>
										<td>正常幼苗%</td>
										<td>新鲜不发芽种子%</td>
										<td>硬实%</td>
										<td>不正常幼苗%</td>
										<td>死种子%</td>
										<td rowspan="4">{{form.gr}}</td>
										<td rowspan="4">{{form.deviation2}}</td>
										<td rowspan="4">{{form.result2}}</td>
									</tr>
									<tr>
										<td>
											<div class="input_td">
												<el-input v-model="form.param5" @input="grInput" type="number"></el-input>
											</div>
										</td>
										<td>
											<div class="input_td">
												<el-input v-model="form.param6" ></el-input>
											</div>
										</td>
										<td>
											<div class="input_td">
												<el-input v-model="form.param7" ></el-input>
											</div>
										</td>
										<td>
											<div class="input_td">
												<el-input v-model="form.param8" ></el-input>
											</div>
										</td>
										<td>
											<div class="input_td">
												<el-input v-model="form.param9" ></el-input>
											</div>
										</td>
									</tr>
									<tr>
										<td colspan="5">
											发芽床{{form.param10}}，温度{{form.param11}}℃
										</td>
									</tr>
									<tr>
										<td colspan="5">
											试验持续时间{{form.param12}}天，发芽前处理和方法：无
										</td>
									</tr>
									<tr>
										<td>3</td>
										<td>水分</td>
										<td colspan="5">
											{{form.param13}}
											<el-input v-model="form.param14" @input="waterInput" type="number" style="width: 80px"></el-input>
										</td>
										<!--<td>-->
											<!--<div class="input_td">-->
												<!--<el-input v-model="form.param14" @input="waterInput" type="number" ></el-input>-->
											<!--</div>-->
										<!--</td>-->
										<td>{{form.water}}</td>
										<td>{{form.deviation3}}</td>
										<td>{{form.result3}}</td>
									</tr>
								</table>
							</div>
						</el-form>
					</div>
				</el-card>
			</div>
            <el-dialog  :visible.sync="dialog1" width="50%">
                <el-form :model="form">
                    <el-form-item label="其他植物种子的种类及数目:">
                        <el-input v-model="form.param15" ></el-input>
                    </el-form-item>
                    <el-form-item label="杂质的种类:">
                        <el-input v-model="form.param16" ></el-input>
                    </el-form-item>
                </el-form>
            </el-dialog>
		</div>

		<script>
			new Vue({
				el: '#app',
				data: {
					/** 基础参数 ***/
					/*****/
					authors:[
							'肖婉玉','张三'
					],
                    dialog1:false,
					form: {
						cropType:'',
						ypNo: 'GZJ2105001',
						bgNo:'BJ',
						si:'',
						gr:'',
						water:'',
						deviation1:'',
						deviation2:'',
						deviation3:'',
						result1:'',
						result2:'',
						result3:'',
						param1:'',
						param2:'',
						param3:'',
						param4:'',
						param5:'',
						param6:'',
						param7:'',
						param8:'',
						param9:'',
						param10:'',
						param11:'',
						param12:'',
						param13:'',
						param14:'',
						param15:'',
						param16:'',
					}
				},
				watch: {
					// form监听
				    form: {
				         handler: function(val) { 
				             var bg1 = window.cache.getItemData(this.index,'bg1');
							 var deviation1 = val.deviation1
							 var deviation2 = val.deviation2
							 if(deviation1 == '-' && deviation2 == '-'){
								 bg1.remark = '--'
							 }else if (deviation1 == '-'){
								 bg1.remark = '发芽率结果判定使用容许误差。'
							 } else if(deviation2 == '-'){
								 bg1.remark = '净度结果判定使用容许误差。'
							 } else{
								 bg1.remark = '净度与发芽率结果判定均使用容许误差。'
							 }
				        },
				        deep: true
				    }
				
				} , 
				created() {
					window.cache = window.parent.cache;
					this.index = location.href.substring(location.href.lastIndexOf("=")+1) - 1
					this.getData(this.index)
					this.init()


				},
				
				methods: {
					init(){
						var arr = window.cache.testParam
						for (var i = 0; i < arr.length; i++) {
							if(this.form.cropType == arr[i].c0){
								this.form.param10 = arr[i].c8
								this.form.param11 = arr[i].c9
								this.form.param12 = arr[i].c10
								this.form.param13 = arr[i].c12
								break;
							}
						}
					},
					siInput(val){
						var si = this.form.si
						if(si){
							this.calDeviation1(val,si.substring(1))
							this.calResultData1(val,si.substring(1))
						}
					},
					calDeviation1(val,si){
						if(val - si < 0){
							var testParamItem = {}
							// 获取测试参数
							var testParam = window.cache.testParam
							for(var i = 0;i < testParam.length;i++){
								var item = testParam[i]
								if(this.form.cropType == item.c0){
									testParamItem = item
									break
								}
							}

							// 获取净度参考数据
							var siParam = window.cache.siParam
							for(var i = 0;i < siParam.length;i++){
								var item = siParam[i]
								if(si - item.c0 == 0){
									if(Number(testParamItem.c16) == 1){
										this.form.deviation1 = item.c1
									}else{
										this.form.deviation1 = item.c2
									}
								}
							}
						}else{
							this.form.deviation1 = '-'
						}
					},
					calResultData1(val,si){
						if(val - si >= 0){
							this.form.result1 = '合格'
						}else{
							if(Number(val) + Number(this.form.deviation1) - Number(si) >= 0){
								this.form.result1 = '合格'
							}else{
								this.form.result1 = '不合格'
							}
						}
					},
					grInput(val){
						var gr = this.form.gr
						if(gr){
							this.calDeviation2(val,gr.substring(1))
							this.calResultData2(val,gr.substring(1))
						}
					},
					calDeviation2(val,gr){
						if(val - gr < 0){
							var grParam = window.cache.grParam
							for(var i = 0;i < grParam.length;i++){
								var item = grParam[i]
								if(item.c0 == gr){
									this.form.deviation2 = item.c1
								}
							}
						}else{
							this.form.deviation2 = '-'
						}
					},
					calResultData2(val,gr){
						if(val - gr < 0){
							if(Number(val) + Number(this.form.deviation2) - Number(gr) >= 0){
								this.form.result2 = '合格'
							}else{
								this.form.result2 = '不合格'
							}
						}else{
							this.form.result2 = '合格'
						}
					},

					waterInput(val){
						var water = this.form.water
						if(water){
							if(Number(val) - Number(water.substring(1)) <= 0){
								this.form.result3 = '合格'
							}else{
								this.form.result3 = '不合格'
							}
						}
					},
					/*************************************************/

					getData(){
						var obj = window.cache.getItemData(this.index,'bg2')
						this.form = obj
					},
				}
			})
		</script>
	</body>
</html>
